package controller.gui.mainmenu;

import java.awt.event.ActionEvent;

import javax.swing.JButton;

import controller.BackupMapUser;
import controller.Controller;
import controller.NullStaticObjectException;
import controller.PrimaryButtonController;
import errors.DimensionNotAcceptableException;
import event.numberevent.NumberEvent;
import gui.MapEditorFrame;
import gui.secondary.MapLayerSecondaryMenu;
import controller.StrataNumberUser;
import controller.states.MapElementToAddStateUser;

/**rappresenta il Controller che si occupa di gestire l'inizio del wizard per l'inserimento dei MapLayer
 * 
 * @author koldar
 * @version 1.0
 *
 */
public class MapLayerWizardController extends PrimaryButtonController implements BackupMapUser,StrataNumberUser,MapElementToAddStateUser{

	private MapLayerSecondaryMenu secondaryMenu;
	
	public MapLayerWizardController(JButton button,MapLayerSecondaryMenu menu) {
		super(button);
		this.secondaryMenu=menu;
		this.listenedButton.setEnabled(this.totalStrata.getValue()>0);
	}
	
	@Override
	public void wizardInizializer(ActionEvent arg0)throws NullStaticObjectException, DimensionNotAcceptableException {
		try {
			this.backupmap.setValue(getCurrentmap().clone());
		} catch (CloneNotSupportedException error) {}
		this.mapElementToAddState.setValue(MapElementToAddStateUser.START);
		this.secondaryMenu.setVisible(true);	
	}
	
	/**attivato se e solo se <tt>stratum</tt> ha un valore non nullo
	 * 
	 */
	@Override
	public void idleUserState(NumberEvent<Integer> arg0){
		this.listenedButton.setEnabled(this.totalStrata.getValue()>0);
	}
	
	

}
